idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
5,800
public function open ( $ attributes = array ( ) ) { $ this -> setAttributes ( $ attributes ) ; $ html = '<' . $ this -> tagName . $ this -> renderAttributes ( ) ; if ( $ this -> closeEmpty || $ this -> hasChildren ( ) ) { $ html .= '>' ; } else { $ html .= '/>' ; } return $ html ; }
Render open tag
5,801
public function close ( ) { $ html = '' ; if ( $ this -> closeEmpty || $ this -> hasChildren ( ) ) { $ html .= '</' . $ this -> tagName . '>' ; } return $ html ; }
Render close tag
5,802
public function render ( $ attributes = array ( ) ) { if ( ! $ this -> tagName ) { throw new Exception ( 'tagName is not defined.' ) ; } $ html = $ this -> open ( $ attributes ) ; if ( $ this -> hasChildren ( ) ) { $ html .= $ this -> renderChildren ( ) ; } $ html .= $ this -> close ( ) ; return $ html ; }
Render the whole element .
5,803
private function prepare ( SpecificationInterface $ specification , EntityManager $ entityManager , QueryBuilder $ queryBuilder , AbstractQuery $ query ) { $ entityManager -> createQueryBuilder ( ) -> willReturn ( $ queryBuilder ) ; $ specification -> modify ( $ queryBuilder , $ this -> dqlAlias ) -> willReturn ( $ thi...
Prepare mocks .
5,804
private function checkCookieKey ( Entity \ CookieIdentity $ identity , string $ key ) { if ( $ identity -> matchKey ( $ key ) === true ) { return ; } $ this -> changeIdentityStatus ( $ identity , Entity \ Identity :: STATUS_BLOCKED ) ; $ this -> logger -> warning ( 'compromised cookie' , $ this -> assembleCookieLogDeta...
Verify that the cookie based identity matches the key and if verification is failed disable this given identity
5,805
public function addBlueprint ( array $ parameters ) { $ instance = $ this -> buildEntity ( ) ; $ this -> populateEntity ( $ instance , $ parameters ) ; $ this -> addEntity ( $ instance ) ; return $ instance ; }
Add new domain entity that is constructed using array as values . Each array key will be attempted top match with entity s setter method and provided with the respective array value . It returns the newly created entity .
5,806
private function populateEntity ( $ instance , array $ parameters ) { foreach ( $ parameters as $ key => $ value ) { $ method = 'set' . str_replace ( '_' , '' , $ key ) ; if ( method_exists ( $ instance , $ method ) ) { $ instance -> { $ method } ( $ value ) ; } } }
code that does the actual population of data from the given array in blueprint
5,807
public function addEntity ( HasId $ entity , $ key = null ) { if ( is_null ( $ key ) === false ) { $ this -> replaceEntity ( $ entity , $ key ) ; return ; } $ entityId = $ entity -> getId ( ) ; $ this -> pool [ ] = $ entity ; $ this -> indexed [ $ entityId ] = $ entity ; $ this -> map [ $ entityId ] = $ this -> retriev...
Method for adding already existing domain entity to the collection .
5,808
public function replaceWith ( Collection $ replacement ) { $ this -> pool = [ ] ; $ this -> map = [ ] ; $ this -> indexed = [ ] ; foreach ( $ replacement as $ entity ) { $ this -> addEntity ( $ entity ) ; } }
Replaces all of the domain entities with a content of some other collection
5,809
public function removeEntity ( HasId $ entity ) { $ key = $ entity -> getId ( ) ; if ( $ key !== null ) { unset ( $ this -> pool [ $ this -> map [ $ key ] ] ) ; $ this -> removeIndexEntry ( $ key ) ; } }
Removes an entity from collection .
5,810
public function saveMany ( $ models ) { $ edges = new Collection ; foreach ( $ models as $ model ) { $ edges -> push ( $ this -> save ( $ model , $ properties ) ) ; } return $ edges ; }
Attach an array of models to the parent instance .
5,811
public function QueryLink ( ) { $ vars = $ this -> queryVars ( ) ; unset ( $ vars [ 'Sort' ] ) ; unset ( $ vars [ 'Dir' ] ) ; return Convert :: raw2xml ( $ this -> Link ( 'RegistryFilterForm' ) . '?' . http_build_query ( $ vars ) ) ; }
Get all search query vars except Sort and Dir compiled into a query link . This will escape all the variables to avoid XSS .
5,812
public function OppositeDirection ( ) { $ direction = $ this -> request -> getVar ( 'Dir' ) ; if ( $ direction ) { if ( $ direction == 'ASC' ) { return 'DESC' ; } return 'ASC' ; } if ( $ this -> request -> getVar ( 'Sort' ) ) { return 'DESC' ; } return 'ASC' ; }
Return the opposite direction from the currently sorted column s direction .
5,813
public function canSortBy ( $ property ) { $ canSort = false ; $ singleton = $ this -> dataRecord -> getDataSingleton ( ) ; if ( $ singleton ) { $ properties = explode ( '.' , $ property ) ; $ relationClass = $ singleton -> getRelationClass ( $ properties [ 0 ] ) ; if ( $ relationClass ) { if ( count ( $ properties ) <...
Loosely check if the record can be sorted by a property
5,814
public function Columns ( $ id = null ) { $ singleton = $ this -> dataRecord -> getDataSingleton ( ) ; $ columns = $ singleton -> summaryFields ( ) ; $ list = ArrayList :: create ( ) ; $ result = null ; if ( $ id ) { $ result = $ this -> queryList ( ) -> byId ( $ id ) ; } foreach ( $ columns as $ name => $ title ) { if...
Format a set of columns used for headings and row data
5,815
public function export ( $ request ) { $ dataClass = $ this -> dataRecord -> getDataClass ( ) ; $ resultColumns = $ this -> dataRecord -> getDataSingleton ( ) -> fieldLabels ( ) ; $ filepath = sprintf ( 'export-%s.csv' , date ( 'Y-m-dHis' ) ) ; $ handle = fopen ( 'php://temp/maxmemory:' . ( 1024 * 1024 ) , 'w' ) ; $ co...
Exports out all the data for the current search results . Sends the data to the browser as a CSV file .
5,816
protected function queryList ( ) { $ dataClass = $ this -> dataRecord -> getDataClass ( ) ; if ( ! $ dataClass ) { return ArrayList :: create ( ) ; } $ singleton = $ this -> dataRecord -> getDataSingleton ( ) ; $ list = $ singleton -> get ( ) ; $ filters = [ ] ; foreach ( $ singleton -> config ( ) -> get ( 'searchable_...
Perform a search against the data table .
5,817
protected function queryVars ( ) { $ resultColumns = $ this -> dataRecord -> getDataSingleton ( ) -> getSearchFields ( ) ; $ columns = [ ] ; foreach ( $ resultColumns as $ field ) { $ columns [ $ field -> getName ( ) ] = '' ; } $ arr = array_merge ( $ columns , [ 'action_doRegistryFilter' => 'Filter' , 'Sort' => '' , '...
Compiles all available GET variables for the result columns into an array . Used internally not to be used directly with the templates or outside classes .
5,818
public function getDefaultNodeLabel ( ) { $ label = ( empty ( $ this -> label ) ) ? $ this -> table : $ this -> label ; if ( is_array ( $ label ) && ! empty ( $ label ) ) return $ label ; if ( ! empty ( $ label ) ) { $ label = array_filter ( explode ( ':' , $ label ) ) ; array_splice ( $ label , 0 , 0 ) ; return $ labe...
Get the node labels
5,819
public function canView ( $ member = null ) { $ managedModels = $ this -> getManagedModels ( ) ; if ( count ( $ managedModels ) == 0 ) { return false ; } return parent :: canView ( $ member ) ; }
Hide the registry section completely if we have no registries to manage .
5,820
public function getCsvImportFilename ( ) { $ feed = RegistryImportFeed :: singleton ( ) ; return sprintf ( '%s/%s' , $ feed -> getStoragePath ( $ this -> modelClass ) , $ feed -> getImportFilename ( ) ) ; }
Gets a unique filename to use for importing the uploaded CSV data
5,821
static public function create ( $ driver , array $ settings , array $ optionsOverride = null ) { switch ( $ driver ) { case 'mysql' : return new MysqlExtPDO ( $ settings , $ optionsOverride ) ; case 'pgsql' : return new PostgreSqlExtPDO ( $ settings , $ optionsOverride ) ; case 'sqlite' : return new SqliteExtPDO ( $ se...
Creates an instance of an ExtPDO subclass that matches the given driver name .
5,822
public function create ( string $ className ) { if ( array_key_exists ( $ className , $ this -> cache ) ) { return $ this -> cache [ $ className ] ; } if ( ! class_exists ( $ className ) ) { throw new RuntimeException ( "Mapper not found. Attempted to load '{$className}'." ) ; } $ instance = new $ className ( $ this ->...
Method for retrieving an SQL data mapper instance
5,823
public static function rand ( $ length , $ charsets = array ( 'alpha' , 'number' , 'symbol' ) ) { $ rand = '' ; if ( $ length !== null && $ charsets !== null ) { if ( is_numeric ( $ length ) && is_int ( + $ length ) ) { if ( is_string ( $ charsets ) || is_array ( $ charsets ) ) { if ( is_string ( $ charsets ) ) { $ cha...
Returns a random string
5,824
public static function splitOnFirstAlpha ( $ string ) { $ pieces = array ( ) ; if ( $ string !== null ) { if ( is_string ( $ string ) ) { $ string = trim ( $ string ) ; if ( $ string !== '' ) { $ pieces = array_map ( 'trim' , preg_split ( '/(?=[a-zA-Z])/i' , $ string , 2 ) ) ; } else { $ pieces = array ( ) ; } } else {...
Splits a string on the first alpha character
5,825
public static function strtobytes ( $ string ) { $ val = false ; if ( $ string !== null ) { if ( is_string ( $ string ) ) { $ val = trim ( $ string ) ; $ last = strtolower ( $ val [ strlen ( $ val ) - 1 ] ) ; switch ( $ last ) { case 'g' : $ val *= 1024 ; case 'm' : $ val *= 1024 ; case 'k' : $ val *= 1024 ; break ; de...
Converts a php . ini - like byte notation shorthand to a number of bytes
5,826
public static function strtocamelcase ( $ string ) { if ( $ string !== null ) { if ( is_string ( $ string ) ) { if ( strlen ( $ string ) ) { $ string = trim ( $ string ) ; $ string = str_replace ( array ( '-' , '_' ) , ' ' , $ string ) ; $ string = strtolower ( $ string ) ; $ string = ucwords ( $ string ) ; $ string = ...
Returns a string in camel case
5,827
public static function getNextWhitespace ( $ string , $ start = - 1 ) { while ( $ start < ( strlen ( $ string ) - 1 ) && ! self :: isWhitespace ( $ string [ $ start + 1 ] ) ) { $ start ++ ; } if ( $ start === ( strlen ( $ string ) - 1 ) ) { return false ; } $ start ++ ; return $ start ; }
Get next first whitespace character .
5,828
public static function getPrevWhitespace ( $ string , $ start = null ) { $ start = ( $ start !== null ) ? $ start : strlen ( $ string ) ; while ( $ start > 0 && ! self :: isWhitespace ( $ string [ $ start - 1 ] ) ) { $ start -- ; } if ( $ start === 0 ) { return false ; } $ start -- ; return $ start ; }
Get previous first whitespace character .
5,829
public static function getNextNonWhitespace ( $ string , $ start = - 1 ) { while ( $ start < ( strlen ( $ string ) - 1 ) && self :: isWhitespace ( $ string [ $ start + 1 ] ) ) { $ start ++ ; } if ( $ start === ( strlen ( $ string ) - 1 ) ) { return false ; } $ start ++ ; return $ start ; }
Get next first non whitespace character .
5,830
public static function getPrevNonWhitespace ( $ string , $ start = null ) { $ start = ( $ start !== null ) ? $ start : strlen ( $ string ) ; while ( $ start > 0 && self :: isWhitespace ( $ string [ $ start - 1 ] ) ) { $ start -- ; } if ( $ start === 0 ) { return false ; } $ start -- ; return $ start ; }
Get previous first non whitespace character .
5,831
public static function delAll ( ) { if ( count ( self :: $ _tasks ) > 0 ) { foreach ( self :: $ _tasks as $ k => $ v ) { swoole_timer_clear ( $ k ) ; } self :: $ _tasks = array ( ) ; } }
Remove all timers .
5,832
public function createWith ( array $ model , array $ related ) { $ cypher = $ this -> grammar -> compileCreateWith ( $ this , compact ( 'model' , 'related' ) ) ; $ result = true ; return $ this -> connection -> statement ( $ cypher , [ ] , $ result ) ; }
Create a new node with related nodes with one database hit .
5,833
protected function tableExists ( $ tableName ) { $ found = false ; $ iterator = $ this -> dynamoDb -> getClient ( ) -> getIterator ( 'ListTables' ) ; foreach ( $ iterator as $ table ) { if ( $ table === $ tableName ) { $ found = true ; } } return $ found ; }
Checks if the given table exists .
5,834
private function modifyQueryBuilder ( QueryBuilder $ queryBuilder , SpecificationInterface $ specification ) { $ condition = $ specification -> modify ( $ queryBuilder , $ this -> dqlAlias ) ; if ( empty ( $ condition ) ) { return ; } $ queryBuilder -> where ( $ condition ) ; }
Modifies the QueryBuilder according to the passed Specification . Will also set the condition for this query if needed .
5,835
public function addRow ( $ rows = null ) { if ( ! is_array ( $ rows ) ) { $ rows = func_get_args ( ) ; } $ row = new TableRow ; foreach ( $ rows as $ arg ) { $ cell = new TableCell ; $ cell -> addChild ( $ arg ) ; $ row -> addChild ( $ cell ) ; } $ this -> addChild ( $ row ) ; return $ row ; }
Add elements to a new row
5,836
public function setAssetHandler ( GeneratedAssetHandler $ handler ) { $ handler -> getFilesystem ( ) -> addPlugin ( new ListFiles ) ; $ this -> assetHandler = $ handler ; return $ this ; }
Set the handler used to manipulate the filesystem and add the ListFiles plugin from Flysystem to inspect the contents of a directory
5,837
public function getStoragePath ( $ modelClass = null ) { $ sanitisedClassName = $ this -> sanitiseClassName ( $ modelClass ? : $ this -> modelClass ) ; return str_replace ( '{model}' , $ sanitisedClassName , $ this -> config ( ) -> get ( 'storage_path' ) ) ; }
Get the path that import files will be stored for this model
5,838
public function getImportFilename ( ) { $ datetime = DBDatetime :: now ( ) -> Format ( 'y-MM-dd-HHmmss' ) ; return str_replace ( '{date}' , $ datetime , $ this -> config ( ) -> get ( 'storage_filename' ) ) ; }
Returns a relatively unique filename to storage imported data feeds as
5,839
public function createWith ( array $ attributes , array $ relations ) { $ attributes = $ this -> prepareForCreation ( $ this -> model , $ attributes ) ; $ model = [ 'label' => $ this -> model -> getTable ( ) , 'attributes' => $ attributes ] ; $ related = [ ] ; foreach ( $ relations as $ relation => $ values ) { $ name ...
Create a new record from the parent Model and new related records with it .
5,840
public function Breadcrumbs ( $ maxDepth = 20 , $ unlinked = false , $ stopAtPageType = false , $ showHidden = false , $ delimiter = '&raquo;' ) { $ page = $ this ; $ pages = [ ] ; while ( $ page && ( ! $ maxDepth || count ( $ pages ) < $ maxDepth ) && ( ! $ stopAtPageType || $ page -> ClassName != $ stopAtPageType ) )...
Modified version of Breadcrumbs to cater for viewing items .
5,841
public static function copy ( $ source , $ destination , $ mode = 0777 ) { $ isSuccess = false ; if ( $ source !== null && $ destination !== null && $ mode !== null ) { if ( is_string ( $ source ) ) { if ( is_string ( $ destination ) ) { if ( is_integer ( $ mode ) || $ mode === false ) { if ( is_dir ( $ source ) ) { if...
Copies files or directory to the filesystem
5,842
public static function remove ( $ directory , $ container ) { $ isSuccess = false ; if ( $ directory !== null && $ container !== null ) { if ( is_string ( $ directory ) ) { if ( is_string ( $ container ) ) { if ( is_dir ( $ directory ) ) { if ( is_writable ( $ directory ) ) { if ( \ Jstewmc \ PhpHelpers \ Str :: starts...
Deletes a non - empty directory and its sub - directories
5,843
public function parseType ( Object \ TypeObjectInterface $ type , $ data ) { if ( $ type instanceof Object \ ReferentialInterface && $ type -> hasRef ( ) ) { $ objectType = $ type -> getRef ( ) ; $ type = $ this -> resolveReference ( $ type ) ; } else { try { $ objectType = $ type -> getType ( ) ; } catch ( SwaggerExce...
Parse a type - object with data into its respective structure
5,844
public static function filterBykey ( $ array , $ callback ) { $ filtered = array ( ) ; if ( $ array !== null && $ callback !== null ) { if ( is_array ( $ array ) ) { if ( is_callable ( $ callback ) ) { if ( ! empty ( $ array ) ) { $ keys = array_filter ( array_keys ( $ array ) , $ callback ) ; if ( ! empty ( $ keys ) )...
Filters an array by key
5,845
public static function filterByKeyPrefix ( $ array , $ prefix ) { $ filtered = array ( ) ; if ( $ array !== null && $ prefix !== null ) { if ( is_array ( $ array ) ) { if ( is_string ( $ prefix ) ) { if ( ! empty ( $ array ) ) { $ filtered = self :: filterByKey ( $ array , function ( $ k ) use ( $ prefix ) { return str...
Filters an array by a key prefix
5,846
public static function inArray ( $ needle , $ haystack , $ wildcard = '*' ) { $ inArray = false ; if ( $ needle !== null && $ haystack !== null && $ wildcard !== null ) { if ( is_string ( $ needle ) ) { if ( is_array ( $ haystack ) ) { if ( is_string ( $ wildcard ) ) { if ( strpos ( $ needle , $ wildcard ) !== false ) ...
Wildcard search for a value in an array
5,847
public static function permute ( Array $ set ) { $ perms = [ ] ; $ j = 0 ; $ size = count ( $ set ) - 1 ; $ perm = range ( 0 , $ size ) ; do { foreach ( $ perm as $ i ) { $ perms [ $ j ] [ ] = $ set [ $ i ] ; } } while ( $ perm = self :: getNextPermutation ( $ perm , $ size ) and ++ $ j ) ; return $ perms ; }
Returns an array of this array s permutations
5,848
public static function sortByField ( $ array , $ field , $ sort = 'asc' ) { if ( $ array !== null && $ field !== null && $ sort !== null ) { if ( is_array ( $ array ) ) { if ( is_string ( $ field ) ) { if ( is_string ( $ sort ) ) { if ( in_array ( strtolower ( $ sort ) , array ( 'asc' , 'ascending' , 'desc' , 'descendi...
Sorts an array of associative arrays by a field s value
5,849
public static function sortByProperty ( $ array , $ property , $ sort = 'asc' ) { if ( $ array !== null && $ property !== null && $ sort !== null ) { if ( is_array ( $ array ) ) { if ( is_string ( $ property ) ) { if ( is_string ( $ sort ) ) { if ( in_array ( strtolower ( $ sort ) , array ( 'asc' , 'ascending' , 'desc'...
Sorts an array of objects using a public property s value
5,850
public static function sortByMethod ( $ array , $ method , $ sort = 'asc' ) { if ( $ array !== null && $ method !== null && $ sort !== null ) { if ( is_array ( $ array ) ) { if ( is_string ( $ method ) ) { if ( is_string ( $ sort ) ) { if ( in_array ( strtolower ( $ sort ) , array ( 'asc' , 'ascending' , 'desc' , 'desc...
Sorts an array of objects using a method s return value
5,851
protected static function getNextPermutation ( $ p , $ size ) { for ( $ i = $ size - 1 ; $ i >= 0 && $ p [ $ i ] >= $ p [ $ i + 1 ] ; -- $ i ) { } if ( $ i == - 1 ) { return false ; } for ( $ j = $ size ; $ j >= 0 && $ p [ $ j ] <= $ p [ $ i ] ; -- $ j ) { } $ tmp = $ p [ $ i ] ; $ p [ $ i ] = $ p [ $ j ] ; $ p [ $ j ]...
Returns the next permutation
5,852
public function getContent ( ) { if ( $ this -> _content === null ) { if ( ! $ this -> canRead ( ) ) { throw new Exception ( "Unable to read config file {$this->file}." ) ; } $ buffer = $ this -> getFileContent ( $ this -> file ) ; $ this -> _content = $ this -> jsonDecode ( $ buffer ) ; } return $ this -> _content ; }
The content of the json file as array .
5,853
public function writeContent ( array $ content ) { if ( ! $ this -> canWrite ( ) ) { throw new Exception ( "Unable to write file {this->file}." ) ; } $ json = $ this -> jsonEncode ( $ content ) ; return $ this -> writeFileContent ( $ this -> file , $ json ) ; }
Write the content into the composer . json .
5,854
public function runCommand ( $ command ) { $ folder = dirname ( $ this -> file ) ; $ olddir = getcwd ( ) ; chdir ( $ folder ) ; ob_start ( ) ; $ output = null ; $ cmd = system ( 'composer ' . $ command , $ output ) ; $ output = ob_end_clean ( ) ; chdir ( $ olddir ) ; return $ cmd === false ? false : true ; }
Run a composer command in the given composer . json .
5,855
protected function writeFileContent ( $ file , $ data ) { $ handler = file_put_contents ( $ file , $ data ) ; return $ handler === false ? false : true ; }
Write the file content .
5,856
protected function jsonDecode ( $ json ) { $ content = json_decode ( ( string ) $ json , true ) ; $ this -> handleJsonError ( json_last_error ( ) ) ; return $ content ; }
Decodes a json string into php structure .
5,857
protected function jsonEncode ( array $ data ) { set_error_handler ( function ( ) { $ this -> handleJsonError ( JSON_ERROR_SYNTAX ) ; } , E_WARNING ) ; $ json = json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ; restore_error_handler ( ) ; $ this -> handleJsonError ( json_last_error ( ) ) ; return $ ...
Encodes a php array structure into a json string .
5,858
protected function handleJsonError ( $ error ) { switch ( $ error ) { case JSON_ERROR_NONE : break ; case JSON_ERROR_DEPTH : throw new Exception ( "Maximum stack depth exceeded" ) ; case JSON_ERROR_STATE_MISMATCH : throw new Exception ( "Underflow or the modes mismatch" ) ; case JSON_ERROR_CTRL_CHAR : throw new Excepti...
Handle json parsing errors .
5,859
public function connect ( ) { if ( $ this -> _status !== self :: STATUS_INITIAL && $ this -> _status !== self :: STATUS_CLOSING && $ this -> _status !== self :: STATUS_CLOSED ) { return ; } $ this -> _status = self :: STATUS_CONNECTING ; $ this -> _connectStartTime = microtime ( true ) ; if ( $ this -> _contextOption )...
Do connect .
5,860
public function asDateTime ( $ pattern = 'yyyy/MM/dd, HH:mm:ss' ) { $ this -> setFinalPattern ( $ this -> parsePattern ( $ pattern ) ) ; return $ this -> getIntlDateFormatter ( ) -> format ( $ this -> getIntlCalendar ( ) ) ; }
Return final date and time on supplied format .
5,861
public function fromTimestamp ( $ timestamp , $ timezone = 'UTC' ) { $ oldTz = date_default_timezone_get ( ) ; date_default_timezone_set ( $ timezone ) ; $ timestamp = mktime ( date ( 'H' , $ timestamp ) , date ( 'i' , $ timestamp ) , date ( 's' , $ timestamp ) , date ( 'n' , $ timestamp ) , date ( 'j' , $ timestamp ) ...
Get datetime as a timestamp .
5,862
public function from ( $ datetime = [ ] , $ locale = 'en_US' , $ calendar = null , $ timezone = 'UTC' ) { $ datetime = $ this -> parseDateTime ( $ datetime ) ; $ calendar = $ calendar ? : self :: $ CAL_GREGORIAN ; $ this -> setIntlCalendar ( ) -> setFromCalendar ( $ calendar ) -> setFromLocale ( $ locale ) -> setOrigin...
Get information of datetime on origin .
5,863
public function to ( $ locale = 'en_US' , $ calendar = null , $ timezone = 'UTC' ) { $ calendar = $ calendar !== null ? $ calendar : self :: $ CAL_PERSIAN ; $ this -> setIntlDateFormatter ( ) -> setToCalendar ( $ calendar ) -> setToLocale ( $ locale ) -> setFinalTimeZone ( $ timezone ) -> setFinalCalendar ( $ this -> g...
Convert datetime to a desired calendar .
5,864
private function parseDateTime ( $ datetimeArray ) { $ finalDatetimeArray = [ ] ; if ( ! is_array ( $ datetimeArray ) ) { throw new Exception ( 'DateTime information must be an array in [year, month, day, hours, minutes, seconds] format.' ) ; } $ finalDatetimeArray [ 0 ] = isset ( $ datetimeArray [ 0 ] ) ? ( int ) $ da...
Parse DateTime information array to be in correct format .
5,865
public function createConnection ( ) { $ client = new OriClient ( $ this -> getHost ( ) , $ this -> getPort ( ) , $ this -> getDatabase ( ) ) ; $ client -> getTransport ( ) -> setAuth ( $ this -> getUsername ( ) , $ this -> getPassword ( ) ) ; return $ client ; }
Create a new Orientdb client
5,866
public function getBatchQuery ( $ query , array $ bindings ) { return new BatchQuery ( $ this -> getClient ( ) , $ query , $ this -> prepareBindings ( $ bindings ) ) ; }
Make a query out of a Batch statement and the bindings values
5,867
public function table ( $ table ) { $ query = new Builder ( $ this , $ this -> getQueryGrammar ( ) ) ; return $ query -> from ( $ table ) ; }
Begin a fluent query against a database table . In Orientdb s terminologies this is a node .
5,868
protected function run ( $ query , $ bindings , Closure $ callback ) { $ start = microtime ( true ) ; try { $ result = $ callback ( $ this , $ query , $ bindings ) ; } catch ( \ Exception $ e ) { throw new QueryException ( $ query , $ bindings , $ e ) ; } $ time = $ this -> getElapsedTime ( $ start ) ; $ this -> logQue...
Run a Cypher statement and log its execution context .
5,869
public function send ( CakeEmail $ email ) { if ( Configure :: read ( 'Mailgun.preventManyToRecipients' ) !== false && count ( $ email -> to ( ) ) > 1 ) { throw new Exception ( 'More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)' ) ; } $ mgClient = new Mailgun ( $ th...
Send email via Mailgun
5,870
protected function deleteTables ( ) { if ( empty ( self :: $ tables ) ) { throw new \ Exception ( 'Cannot delete tables, as no configuration file given, or the ::$tables is not overridden.' ) ; } $ client = $ this -> dynamoDb -> getClient ( ) ; $ defaultAnswer = $ this -> input -> getOption ( 'yes' ) ; $ a = 'n' ; fore...
Deletes the tables defined in configuration file or overridden .
5,871
public function compileEdge ( Builder $ query , $ parent , $ related , $ relationship = 'E' , $ values = [ ] ) { $ from = $ this -> columnize ( [ $ parent -> getAttributes ( ) [ $ parent -> getKeyName ( ) ] ] ) ; $ to = $ this -> columnize ( [ $ related -> getAttributes ( ) [ $ related -> getKeyName ( ) ] ] ) ; $ prope...
Compile an Edge statement into SQL .
5,872
public function addCard ( $ params , $ setAsDefault = false ) { if ( is_array ( $ params ) ) { $ result = $ this -> generateToken ( $ params ) ; if ( $ result [ 'status' ] === 'error' ) { return $ result ; } $ token = $ result [ 'token' ] ; } else { $ token = $ params ; } if ( ! $ this -> stripe_id ) { $ customer = $ t...
Adds a card
5,873
public function deleteCard ( $ cardId ) { if ( ! $ this -> stripe_id ) { return [ 'status' => 'error' , 'message' => 'Invalid StripeId' ] ; } try { $ stripe = new Stripe ( Billable :: getStripeKey ( ) ) ; $ card = $ stripe -> cards ( ) -> delete ( $ this -> stripe_id , $ cardId ) ; return [ 'status' => 'success' , 'car...
Deletes a card
5,874
public function generateToken ( array $ params ) { $ stripe = new Stripe ( Billable :: getStripeKey ( ) ) ; try { $ attributes = [ 'card' => [ 'number' => $ params [ 'cardNumber' ] , 'exp_month' => $ params [ 'expiryMonth' ] , 'cvc' => $ params [ 'cvc' ] , 'exp_year' => $ params [ 'expiryYear' ] , ] , ] ; $ token = $ s...
Generates a Stripe Token
5,875
public function getCard ( $ cardId ) { if ( ! $ this -> stripe_id ) { return null ; } $ customer = $ this -> asStripeCustomer ( ) ; foreach ( $ customer -> sources -> data as $ card ) { if ( $ card -> id === $ cardId ) { return $ card ; } } return null ; }
Gets a card
5,876
public function getDefaultCard ( ) { if ( ! $ this -> stripe_id ) { return null ; } $ customer = $ this -> asStripeCustomer ( ) ; foreach ( $ customer -> sources -> data as $ card ) { if ( $ card -> id === $ customer -> default_source ) { return $ card ; } } return null ; }
Returns the default card
5,877
public function getStripeId ( ) { if ( $ this -> stripe_id ) { return $ this -> stripe_id ; } $ customer = $ this -> createAsStripeCustomer ( null ) ; return $ customer -> id ; }
Gets a users stripeId Or generates a new one if the user doesn t have one
5,878
public function updateDefaultCard ( $ cardId ) { $ customer = $ this -> asStripeCustomer ( ) ; $ customer -> default_source = $ cardId ; $ result = $ customer -> save ( ) ; $ card = $ this -> getCard ( $ cardId ) ; $ this -> card_brand = $ card -> brand ; $ this -> card_last_four = $ card -> last4 ; $ this -> save ( ) ...
Updates the default card
5,879
public function render ( $ attributes = null ) { if ( $ attributes ) $ this -> setAttributes ( $ attributes ) ; return '<textarea' . $ this -> renderAttributes ( ) . '>' . htmlspecialchars ( $ this -> value , ENT_NOQUOTES , 'UTF-8' ) . '</textarea>' ; }
Render Widget with attributes
5,880
public static function getImageFileProperties ( $ path ) { if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( 'The image file does not exist.' ) ; } $ info = getimagesize ( $ path ) ; if ( ! $ info ) { throw new \ RuntimeException ( 'Unable to get properties for the image.' ) ; } $ properties = ( ...
Method to return a properties object for an image given a filesystem path .
5,881
private static function getOrientationString ( $ width , $ height ) { switch ( true ) { case $ width > $ height : return self :: ORIENTATION_LANDSCAPE ; case $ width < $ height : return self :: ORIENTATION_PORTRAIT ; default : return self :: ORIENTATION_SQUARE ; } }
Compare width and height integers to determine image orientation .
5,882
public function createThumbs ( $ thumbSizes , $ creationMethod = self :: SCALE_INSIDE , $ thumbsFolder = null ) { if ( ! $ this -> isLoaded ( ) ) { throw new \ LogicException ( 'No valid image was loaded.' ) ; } if ( $ thumbsFolder === null ) { $ thumbsFolder = \ dirname ( $ this -> getPath ( ) ) . '/thumbs' ; } if ( !...
Method to create thumbnails from the current image and save them to disk . It allows creation by resizing or cropping the original image .
5,883
public function loadFile ( $ path ) { $ this -> destroy ( ) ; if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( 'The image file does not exist.' ) ; } $ properties = static :: getImageFileProperties ( $ path ) ; switch ( $ properties -> mime ) { case 'image/gif' : if ( empty ( static :: $ formats...
Method to load a file into the Image object as the resource .
5,884
public function cropResize ( $ width , $ height , $ createNew = true ) { $ width = $ this -> sanitizeWidth ( $ width , $ height ) ; $ height = $ this -> sanitizeHeight ( $ height , $ width ) ; $ resizewidth = $ width ; $ resizeheight = $ height ; if ( ( $ this -> getWidth ( ) / $ width ) < ( $ this -> getHeight ( ) / $...
Method to crop an image after resizing it to maintain proportions without having to do all the set up work .
5,885
public function flip ( $ mode , $ createNew = true ) { $ handle = imagecreatetruecolor ( $ this -> getWidth ( ) , $ this -> getHeight ( ) ) ; imagecopy ( $ handle , $ this -> getHandle ( ) , 0 , 0 , 0 , 0 , $ this -> getWidth ( ) , $ this -> getHeight ( ) ) ; if ( ! imageflip ( $ handle , $ mode ) ) { throw new \ Logic...
Method to flip the current image .
5,886
public function watermark ( Image $ watermark , $ transparency = 50 , $ bottomMargin = 0 , $ rightMargin = 0 ) { imagecopymerge ( $ this -> getHandle ( ) , $ watermark -> getHandle ( ) , $ this -> getWidth ( ) - $ watermark -> getWidth ( ) - $ rightMargin , $ this -> getHeight ( ) - $ watermark -> getHeight ( ) - $ bot...
Watermark the image
5,887
protected function sanitizeWidth ( $ width , $ height ) { $ width = ( $ width === null ) ? $ height : $ width ; if ( preg_match ( '/^[0-9]+(\.[0-9]+)?\%$/' , $ width ) ) { $ width = ( int ) round ( $ this -> getWidth ( ) * ( float ) str_replace ( '%' , '' , $ width ) / 100 ) ; } else { $ width = ( int ) round ( ( float...
Method to sanitize a width value .
5,888
public function getAvailableFormats ( ) { try { $ ret = array ( ) ; $ result = $ this -> getSoapClient ( ) -> GetDocumentFormats ( ) ; if ( isset ( $ result -> GetDocumentFormatsResult -> string ) ) { $ ret = $ result -> GetDocumentFormatsResult -> string ; $ ret = array_map ( 'strtolower' , $ ret ) ; } return $ ret ; ...
Return a list of all available return formats you can ask for when generating the document
5,889
public function setPassword ( $ password ) { try { $ this -> getSoapClient ( ) -> SetDocumentPassword ( array ( 'password' => $ password , ) ) ; return $ this ; } catch ( SoapException $ ex ) { throw new PasswordException ( 'Error while setting a password for the document' , $ ex ) ; } }
Set a password for the generated document
5,890
public function setPermissions ( $ permissions , $ password ) { if ( ! is_array ( $ permissions ) || ! is_string ( $ password ) || $ password === '' ) { throw new InvalidException ( 'Permissions and password must be respectively an array and a string' ) ; } try { $ this -> getSoapClient ( ) -> SetDocumentAccessPermissi...
Set a master password and a list of features accessible without this password
5,891
public function getAccessOptions ( ) { try { $ ret = array ( ) ; $ result = $ this -> getSoapClient ( ) -> GetDocumentAccessOptions ( ) ; if ( isset ( $ result -> GetDocumentAccessOptionsResult -> string ) ) { $ ret = $ result -> GetDocumentAccessOptionsResult -> string ; } return $ ret ; } catch ( SoapException $ ex )...
Return a list of permissions you can use in setPermissions
5,892
public function retrieve ( $ format = null ) { if ( is_null ( $ format ) ) { $ format = $ this -> format ; } if ( is_null ( $ format ) ) { throw new InvalidException ( 'You must provide a format to retrieve the document' ) ; } $ format = strtolower ( $ format ) ; try { $ result = $ this -> getSoapClient ( ) -> Retrieve...
Retrieve the final document from Livedocx service . If you didn t provide a format for retrieval using the setFormat method you can do it here .
5,893
protected function getPaginatedMetaFiles ( $ from , $ to ) { if ( $ from > $ to ) { throw new InvalidException ( 'Start page for metafiles must be inferior to end page' ) ; } $ ret = array ( ) ; try { $ result = $ this -> getSoapClient ( ) -> GetMetafiles ( array ( 'fromPage' => ( integer ) $ from , 'toPage' => ( integ...
Get a paginated list of document as Metafile images .
5,894
protected function getAllMetafiles ( ) { $ ret = array ( ) ; try { $ result = $ this -> getSoapClient ( ) -> GetAllMetafiles ( ) ; } catch ( SoapException $ ex ) { throw new MetafilesException ( 'Error while retrieving the document from Livedocx service' , $ ex ) ; } if ( isset ( $ result -> GetAllMetafilesResult -> st...
Get a complete list of document as Metafile images .
5,895
protected function getPaginatedBitmaps ( $ zoomFactor , $ format , $ from , $ to ) { if ( $ from > $ to ) { throw new InvalidException ( 'Start page for bitmaps must be inferior to end page' ) ; } $ ret = array ( ) ; try { $ result = $ this -> getSoapClient ( ) -> GetBitmaps ( array ( 'fromPage' => ( integer ) $ from ,...
Retrieve the final document as a list of paginated bitmap files
5,896
protected function getAllBitmaps ( $ zoomFactor , $ format ) { $ ret = array ( ) ; try { $ result = $ this -> getSoapClient ( ) -> GetAllBitmaps ( array ( 'zoomFactor' => ( integer ) $ zoomFactor , 'format' => ( string ) $ format , ) ) ; } catch ( SoapException $ ex ) { throw new BitmapsException ( 'Error while retriev...
Retrieve the final document as a list of bitmap files
5,897
public function getDataCache ( ) { $ key = $ this -> generateKey ( ) ; return $ this -> getRepository ( ) -> getMongator ( ) -> getDataCache ( ) -> get ( $ key ) ; }
Returns the data in cache .
5,898
public function getTTL ( ) { if ( is_null ( $ this -> expiration ) ) { return null ; } if ( $ this -> expiration > $ _SERVER [ 'REQUEST_TIME' ] ) { return $ this -> expiration - $ _SERVER [ 'REQUEST_TIME' ] ; } return 0 ; }
Return the time - to - live for this entry .
5,899
public function clearEmbeddedsOneChanged ( ) { if ( isset ( $ this -> data [ 'embeddedsOne' ] ) ) { foreach ( $ this -> data [ 'embeddedsOne' ] as $ name => $ embedded ) { $ this -> getArchive ( ) -> remove ( 'embedded_one.' . $ name ) ; } } }
Clear the embedded ones changed that is they will not be changed apart from here .