idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
58,300
public function andThrow ( $ e ) { if ( ! $ e instanceof \ Exception ) { if ( is_scalar ( $ e ) && class_exists ( $ e ) && is_a ( $ e , '\Exception' , true ) ) { $ e = new $ e ( "Generic message" ) ; } else { throw new \ LogicException ( "Can only create exceptions on-the-fly with a scalar message" ) ; } } $ this -> an...
Throw the provided expectation when called .
58,301
public function andReturnValues ( array $ returnValues ) { $ this -> andReturn ( function ( ) use ( & $ returnValues ) { if ( count ( $ returnValues ) > 1 ) { return array_shift ( $ returnValues ) ; } else { return current ( $ returnValues ) ; } } ) ; return $ this ; }
Return each of the specified values on consecutive calls .
58,302
public function times ( $ times = null ) { if ( $ this -> atLeastWasCalled && $ times !== null ) { $ this -> atLeastWasCalled = false ; $ this -> atLeast ( $ times ) ; } elseif ( $ times !== null ) { if ( $ times === 0 ) { $ this -> never ( ) ; } else { $ count = 0 ; $ this -> expectation -> setPostPerformCallback ( fu...
The method should be called this number of times .
58,303
public function atLeast ( $ times = null ) { if ( $ times === null ) { $ this -> atLeastWasCalled = true ; } else { $ count = 0 ; $ this -> expectation -> setPostPerformCallback ( function ( ) use ( & $ count , $ times ) { $ this -> commentBuilder -> incrementCallCount ( ) ; $ count ++ ; if ( $ count >= $ times ) { $ t...
The method should be called at least this many times .
58,304
public function registerDecoder ( DecoderInterface $ decoder ) { if ( ! in_array ( $ decoder , $ this -> decoders ) ) { $ this -> decoders [ ] = $ decoder ; } }
Register a decoder in this chain
58,305
public function getJSONString ( ) { $ json = '{' . '"@context":"' . SocialRecord :: JSONLD_CONTEXT . '",' . '"@type":"' . SocialRecord :: JSONLD_TYPE . '",' . '"type":"' . $ this -> type . '",' . '"globalID":"' . $ this -> globalID . '",' . '"platformGID":"' . $ this -> platformGID . '",' . '"displayName":"' . $ this -...
Serialization method for SocialRecord
58,306
public function verify ( ) { if ( $ this -> type != SocialRecord :: TYPE_PLATFORM && $ this -> type != SocialRecord :: TYPE_USER && $ this -> type != SocialRecord :: TYPE_PAGE ) throw new SocialRecordFormatException ( 'invalid type value [' . $ this -> type . ']' ) ; if ( ! GID :: isValid ( $ this -> globalID ) ) throw...
Runs a validation of the structure of the SocialRecord
58,307
public function after ( $ expression = null , $ test = false , $ limit = LIMIT_AFTER ) { if ( isset ( $ this -> after ) && $ limit == LIMIT_AFTER ) { $ after = $ this -> after ; } else { $ after = substr ( $ this -> data , $ this -> end , $ this -> end + $ limit ) ; $ this -> after = $ after ; } if ( $ test === false )...
Perform a forwards search of the data and return a Token representing the expression matched and its position .
58,308
public function before ( $ expression = null , $ test = false , $ limit = LIMIT_BEFORE ) { if ( isset ( $ this -> before ) && $ limit == LIMIT_BEFORE ) { $ before = $ this -> before ; } else { $ limit = max ( 0 , $ this -> begin - $ limit ) ; $ before = substr ( $ this -> data , $ limit , $ this -> begin - $ limit ) ; ...
Perform a backwards search of the data and return a Token representing the expression matched and its position .
58,309
public function move ( Token $ token ) { $ this -> begin = $ token -> begin ; $ this -> end = $ token -> end ; unset ( $ this -> after , $ this -> before ) ; }
Move the internal cursor to the position of a token .
58,310
public static function find ( $ code ) { $ code = strtoupper ( $ code ) ; $ currencies = static :: all ( ) ; if ( isset ( $ currencies [ $ code ] ) ) { return new static ( $ code , $ currencies [ $ code ] [ 'numeric' ] , $ currencies [ $ code ] [ 'decimals' ] ) ; } return null ; }
Find a specific currency
58,311
public function _add_sns_account_fields ( $ user_contactmethods = [ ] ) { $ sns_accounts = $ this -> _sns_accounts ( ) ; unset ( $ sns_accounts [ 'url' ] ) ; $ user_contactmethods = array_merge ( $ user_contactmethods , $ sns_accounts ) ; return $ user_contactmethods ; }
Adds sns account fields
58,312
protected function _sns_accounts ( ) { $ user_contactmethods = apply_filters ( 'inc2734_wp_profile_box_sns_accounts' , [ 'url' => __ ( 'Web Site' , 'inc2734-wp-profile-box' ) , 'twitter' => __ ( 'Twitter' , 'inc2734-wp-profile-box' ) , 'facebook' => __ ( 'Facebook' , 'inc2734-wp-profile-box' ) , 'instagram' => __ ( 'In...
Adds SNS accounts settings
58,313
protected function _get_detail_page_url ( $ user_id ) { $ detail_keys = $ this -> _add_detail_url_field ( ) ; $ detail_keys = array_keys ( $ detail_keys ) ; foreach ( $ detail_keys as $ key ) { $ detail_url = get_the_author_meta ( $ key , $ user_id ) ; if ( $ detail_url ) { return $ detail_url ; } } }
Returns detail page URL
58,314
protected function _get_sns_accounts ( $ user_id ) { $ sns_accounts = $ this -> _sns_accounts ( ) ; $ sns_account_keys = array_keys ( $ sns_accounts ) ; $ sns_accounts = [ ] ; foreach ( $ sns_account_keys as $ sns_account_key ) { $ sns_account = get_the_author_meta ( $ sns_account_key , $ user_id ) ; if ( ! $ sns_accou...
Returns SNS account URLs
58,315
private function parseFile ( string $ path ) : array { $ json = json_decode ( file_get_contents ( $ path ) , true ) ; $ root = dirname ( $ path ) ; $ namespaces = array_merge ( iterator_to_array ( $ this -> parseNamespaces ( $ json [ 'autoload' ] [ 'psr-4' ] ? : [ ] , $ root ) ) , iterator_to_array ( $ this -> parseNam...
Parses namespaces from a composer . json file .
58,316
private function parseNamespaces ( array $ config , string $ root ) : Generator { foreach ( $ config as $ name => $ paths ) { $ paths = is_array ( $ paths ) ? $ paths : [ $ paths ] ; foreach ( $ paths as $ path ) { $ path = realpath ( $ root . '/' . $ path ) ; if ( ! $ path ) { continue ; } yield new Psr4Namespace ( $ ...
Parses namespaces from a configuration section .
58,317
public function Base_AfterCommentFormat_Handler ( $ Sender ) { if ( ! C ( 'Plugins.Emotify.FormatEmoticons' , TRUE ) ) return ; $ Object = $ Sender -> EventArguments [ 'Object' ] ; $ Object -> FormatBody = $ this -> DoEmoticons ( $ Object -> FormatBody ) ; $ Sender -> EventArguments [ 'Object' ] = $ Object ; }
Replace emoticons in comments .
58,318
public function PostController_AfterCommentPreviewFormat_Handler ( $ Sender ) { if ( ! C ( 'Plugins.Emotify.FormatEmoticons' , TRUE ) ) return ; $ Sender -> Comment -> Body = $ this -> DoEmoticons ( $ Sender -> Comment -> Body ) ; }
Replace emoticons in comment preview .
58,319
private function _EmotifySetup ( $ Sender ) { $ Sender -> AddJsFile ( 'emotify.js' , 'plugins/Emotify' ) ; $ Emoticons = array ( ) ; foreach ( $ this -> GetEmoticons ( ) as $ i => $ gif ) { if ( ! isset ( $ Emoticons [ $ gif ] ) ) $ Emoticons [ $ gif ] = $ i ; } $ Emoticons = array_flip ( $ Emoticons ) ; $ Sender -> Ad...
Prepare a page to be emotified .
58,320
public function dateFormat ( $ date , string $ format = 'M d Y' ) : string { if ( $ date instanceof DateTime ) { return $ date -> format ( $ format ) ; } elseif ( is_int ( $ date ) ) { return date ( $ format , $ date ) ; } return date ( $ format , strtotime ( $ date ) ) ; }
Return a formatted date string .
58,321
public function paginate ( Paginator $ model ) : string { return with ( new SemanticUIPagination ( $ model -> appends ( $ this -> request -> query ( ) ) ) ) -> render ( ) ; }
Use a custom pagination style .
58,322
public function set ( string $ key , $ value ) : Definition { $ this -> data [ $ key ] = $ value ; return $ this ; }
Set a value for the given key .
58,323
public function get ( string $ key ) { if ( ! $ this -> has ( $ key ) ) { throw new \ InvalidArgumentException ( 'Key "' . $ key . '" does not exist.' ) ; } return $ this -> data [ $ key ] ; }
Obtain the value for the given key .
58,324
protected function compileAllFiles ( ) { $ preloader = new ClassPreloader ( new PrettyPrinter , new Parser ( new Lexer ) , $ this -> getTraverser ( ) ) ; $ handle = $ preloader -> prepareOutput ( $ this -> getContainer ( ) -> getCompiledPath ( ) ) ; foreach ( $ this -> getAllFiles ( ) as $ file ) { try { fwrite ( $ han...
compile all files for the better performance
58,325
protected function getTraverser ( ) { $ traverser = new NodeTraverser ( ) ; $ traverser -> addVisitor ( new DirVisitor ( true ) ) ; $ traverser -> addVisitor ( new FileVisitor ( true ) ) ; return $ traverser ; }
Get the node traverser used by the command .
58,326
protected function getAllFiles ( ) { $ core = require __DIR__ . '/Optimize/core.php' ; $ proivers = config ( 'compile.providers' ) ; $ aliases = config ( 'compile.aliases' ) ; $ files = array_merge ( $ core , $ proivers , $ aliases ) ; return $ files ; }
compile all files
58,327
public function query ( $ parent , array $ parameters , array $ opts = [ ] , array $ ctor = [ ] ) { return $ this -> adapter -> query ( $ parent , $ parameters , $ opts , $ ctor ) ; }
Query multiple models in an Adapter - independent way .
58,328
public function save ( ) { if ( $ this -> isNew ( ) ) { return $ this -> adapter -> create ( $ this ) ; } else { return $ this -> adapter -> update ( $ this ) ; } }
Persist this model back to whatever storage Adapter it was constructed with .
58,329
private function export ( ) { $ exported = new StdClass ; foreach ( $ this as $ name => $ field ) { if ( ( new ReflectionProperty ( $ this , $ name ) ) -> isPublic ( ) ) { if ( is_object ( $ field ) ) { $ traits = class_uses ( $ field ) ; if ( isset ( $ traits [ 'Ornament\Model' ] ) || isset ( $ traits [ 'Ornament\Json...
Internal helper method to export the model s public properties .
58,330
public function generate_schema ( ) { $ schema = "CREATE TABLE `" . $ this -> name . "` (\n" ; for ( $ i = 0 ; $ i < count ( $ this -> details ) ; $ i ++ ) { if ( ! isset ( $ this -> details [ $ i ] [ 'options' ] ) ) { $ this -> details [ $ i ] [ 'options' ] = array ( ) ; } $ schema .= "`" . $ this -> details [ $ i ] [...
Generate schema for a table . Makes files and returns text in api format
58,331
function signUp ( ) { if ( isset ( $ _POST [ 'data' ] ) && trim ( $ _POST [ 'data' ] ) !== '' ) { $ private = file_get_contents ( _CONFIG . 'Key/private.key' ) ; $ key = json_decode ( $ _POST [ 'data' ] ) ; $ key = base64_decode ( $ key -> enc ) ; if ( ! openssl_private_decrypt ( $ key , $ key , openssl_pkey_get_privat...
Retorna o0s dados encriptados por AES com o Token como Sincrono Key
58,332
function access ( ) { $ data [ 'agent' ] = $ _SERVER [ 'HTTP_USER_AGENT' ] ; $ data [ 'ip' ] = $ _SERVER [ 'REMOTE_ADDR' ] ; $ data [ 'method' ] = $ _SERVER [ 'REQUEST_METHOD' ] ; $ data [ 'uri' ] = $ _SERVER [ 'REQUEST_URI' ] ; $ data [ 'data' ] = date ( 'Y-m-d H:i:s' ) ; ( new Model \ Xlog ) -> setAccessData ( $ data...
Escrevendo dados de acesso no banco de dados
58,333
public function tLog ( string $ level , string $ message , array $ context = [ ] ) { $ logtag = $ this -> getLogTag ( ) ; if ( is_array ( $ message ) || is_object ( $ message ) ) { $ message = print_r ( $ message , true ) ; } $ this -> log ( $ level , "[{time}] [{$logtag}] " . $ message , $ context ) ; }
Log tagged message
58,334
public function dispatch ( ... $ params ) { $ allowedMethods = $ this -> getAllowedMethods ( ) ; if ( $ allowedMethods !== null && ! in_array ( $ this -> request -> getMethod ( ) , $ allowedMethods ) ) { } $ apiMethod = $ this -> route -> getValue ( 'api_method' , 'list' ) ; return call_user_func_array ( array ( $ this...
Dispatch the API routes .
58,335
public function findByModule ( ModuleInterface $ module = null , array $ orderBy = null , $ limit = null , $ offset = null ) { $ criteria = [ ] ; if ( $ this -> isModular ( $ module ) ) { $ criteria [ 'module' ] = $ module ; } return $ this -> findBy ( $ criteria , $ orderBy , $ limit , $ offset ) ; }
Find entities by a Module instance .
58,336
private function queryFirstDate ( $ assetTypeCode ) { $ query = $ this -> qbGetFirstDate -> build ( ) ; $ bind = [ $ this -> qbGetFirstDate :: BND_ASSET_TYPE_CODE => $ assetTypeCode ] ; $ conn = $ query -> getConnection ( ) ; $ result = $ conn -> fetchOne ( $ query , $ bind ) ; return $ result ; }
Get applied date for the first transaction fir the given asset type .
58,337
public function createFromArray ( $ class , array $ attributes ) { $ entity = new $ class ( ) ; foreach ( $ attributes as $ name => $ value ) { if ( property_exists ( $ entity , $ name ) ) { $ methodName = $ this -> getSetterName ( $ entity , $ name ) ; if ( $ methodName ) { $ entity -> { $ methodName } ( $ value ) ; }...
Create entity and assign entity properties using an array
58,338
public function findByIssue ( $ issueId ) { $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ queryBuilder -> leftJoin ( 'p.issues' , 'i' ) ; $ this -> addCriteria ( $ queryBuilder , [ 'i.id' => $ issueId ] ) ; return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Finds all the repositories of issue id given .
58,339
protected function a2k ( & $ dest , $ orig , $ currentKey ) { if ( is_array ( $ orig ) && ( count ( $ orig ) > 0 ) ) { foreach ( $ orig as $ key => $ value ) { if ( is_array ( $ value ) ) { $ this -> a2k ( $ dest , $ value , ( $ currentKey ? $ currentKey . '.' : '' ) . $ key ) ; } else { $ dest [ ( $ currentKey ? $ cur...
associative array indexed to dimensional associative array of keys
58,340
protected function getYamlAsArray ( $ file ) { if ( file_exists ( $ file ) ) { $ content = Yaml :: parse ( file_get_contents ( $ file ) ) ; $ result = array ( ) ; $ this -> a2k ( $ result , $ content , '' ) ; return $ result ; } else { return array ( ) ; } }
Reads a Yaml file and process the keys and returns as a associative indexed array
58,341
protected function k2a ( $ orig ) { $ result = array ( ) ; foreach ( $ orig as $ key => $ value ) { if ( $ value === null ) { } else { $ keys = explode ( '.' , $ key ) ; $ node = $ value ; for ( $ i = count ( $ keys ) ; $ i > 0 ; $ i -- ) { $ k = $ keys [ $ i - 1 ] ; $ node = array ( $ k => $ node ) ; } $ result = arra...
dimensional associative array of keys to associative array indexed
58,342
public function setLogDir ( $ logDir ) { $ logDir = trim ( $ logDir ) ; if ( ! file_exists ( $ logDir ) || ! is_writable ( $ logDir ) ) { throw new \ InvalidArgumentException ( "Invalid log directory!" ) ; } $ this -> _logDir = $ logDir ; }
Setter for log dir
58,343
public function logException ( \ Exception $ exception , $ prefix = "Exception thrown" ) { $ class = new \ ReflectionClass ( $ exception ) ; $ this -> logger -> critical ( "$prefix [{$class->getName()}] {$exception->getMessage()} on line {$exception->getLine()} of {$exception->getFile()}\n" ) ; $ this -> logger -> debu...
Logs any exceptions that are thrown by running jobs .
58,344
private function runJob ( $ job ) { try { $ this -> logger -> notice ( "Job #{$this->currentJobId} [{$job->getName()}] started." ) ; $ status = $ this -> broker -> getStatus ( $ job -> getId ( ) ) ; $ status [ 'status' ] = Job :: STATUS_RUNNING ; $ status [ 'started' ] = date ( DATE_RFC3339_EXTENDED ) ; $ this -> broke...
Actually run a job and log any exceptions or status messages .
58,345
private function executeJob ( Job $ job ) { $ this -> currentJobId = $ job -> getId ( ) ; $ job -> setLogger ( $ this -> logger ) ; $ this -> logger -> notice ( "Starting job #" . $ this -> currentJobId ) ; if ( ! function_exists ( 'pcntl_fork' ) ) { $ this -> runJob ( $ job ) ; return ; } $ pid = pcntl_fork ( ) ; if (...
Fork off this process and wait while job is executed .
58,346
public function mainLoop ( ) { $ bootstrap = $ this -> config -> get ( 'bootstrap' ) ; if ( $ bootstrap ) { ( function ( ) { require $ this -> config -> get ( 'bootstrap' ) ; } ) ( ) ; } $ this -> logger -> info ( "Ajumamoro" ) ; set_error_handler ( function ( $ no , $ message , $ file , $ line ) { $ this -> logger -> ...
The runners main loop that waits on the broker for jobs .
58,347
public function getNextJob ( ) { $ jobInfo = $ this -> broker -> get ( ) ; if ( ! class_exists ( $ jobInfo [ 'class' ] ) ) { $ this -> logger -> error ( "Class {$jobInfo['class']} for scheduled job not found" ) ; return false ; } $ job = unserialize ( $ jobInfo [ 'object' ] ) ; if ( is_object ( $ job ) && is_a ( $ job ...
Get the next job from the broker if any exists . Ths function actuall polls the broker for any pending jobs to be executed .
58,348
public function render ( ) { $ vars = [ 'menu' => $ this , 'items' => $ this -> get ( 'root' ) -> getChildren ( ) ] ; $ rendered = $ this -> viewFactory -> make ( $ this -> view ) -> with ( $ vars ) -> render ( ) ; return $ rendered ; }
Renders the menu using the defined view
58,349
public function add ( $ id , $ value , $ parent = 'root' , array $ meta = [ ] , array $ attributes = [ ] ) { $ node = new Node ( $ id , $ this , $ value , $ meta , $ attributes ) ; if ( ! is_null ( $ parent ) and $ this -> items -> has ( $ parent ) ) { $ parentNode = $ this -> items -> get ( $ parent ) ; $ parentNode -...
Add a menu item
58,350
public function getBreadcrumbToHref ( $ href ) { $ item = $ this -> findItemByHref ( $ href ) ; if ( $ item ) { return $ this -> getBreadcrumbTo ( $ item ) ; } else { return [ ] ; } }
Get breadcrumbs to the Node that has the href
58,351
public static function get ( $ path , array $ config = array ( ) , $ area = null ) { return static :: instance ( $ area ) -> get_handler ( $ path , $ config ) ; }
File & directory objects factory
58,352
public static function get_url ( $ path , array $ config = array ( ) , $ area = null ) { return static :: get ( $ path , $ config , $ area ) -> get_url ( ) ; }
Get the url .
58,353
public static function exists ( $ path , $ area = null ) { $ path = rtrim ( static :: instance ( $ area ) -> get_path ( $ path ) , '\\/' ) ; while ( $ path and is_link ( $ path ) ) { $ path = readlink ( $ path ) ; } return is_file ( $ path ) ; }
Check for file existence
58,354
public static function create_dir ( $ basepath , $ name , $ chmod = null , $ area = null ) { $ basepath = rtrim ( static :: instance ( $ area ) -> get_path ( $ basepath ) , '\\/' ) . DS ; $ new_dir = static :: instance ( $ area ) -> get_path ( $ basepath . trim ( $ name , '\\/' ) ) ; is_null ( $ chmod ) and $ chmod = \...
Create an empty directory
58,355
public static function get_permissions ( $ path , $ area = null ) { $ path = static :: instance ( $ area ) -> get_path ( $ path ) ; if ( ! file_exists ( $ path ) ) { throw new \ InvalidPathException ( 'Path: "' . $ path . '" is not a directory or a file, cannot get permissions.' ) ; } return substr ( sprintf ( '%o' , f...
Get the octal permissions for a file or directory
58,356
public static function get_time ( $ path , $ type = 'modified' , $ area = null ) { $ path = static :: instance ( $ area ) -> get_path ( $ path ) ; if ( ! file_exists ( $ path ) ) { throw new \ InvalidPathException ( 'Path: "' . $ path . '" is not a directory or a file, cannot get creation timestamp.' ) ; } if ( $ type ...
Get a file s or directory s created or modified timestamp .
58,357
public static function rename ( $ path , $ new_path , $ source_area = null , $ target_area = null ) { $ path = static :: instance ( $ source_area ) -> get_path ( $ path ) ; $ new_path = static :: instance ( $ target_area ? : $ source_area ) -> get_path ( $ new_path ) ; return rename ( $ path , $ new_path ) ; }
Rename directory or file
58,358
public static function symlink ( $ path , $ link_path , $ is_file = true , $ area = null ) { $ path = rtrim ( static :: instance ( $ area ) -> get_path ( $ path ) , '\\/' ) ; $ link_path = rtrim ( static :: instance ( $ area ) -> get_path ( $ link_path ) , '\\/' ) ; if ( $ is_file and ! is_file ( $ path ) ) { throw new...
Create a new symlink
58,359
public static function close_file ( $ resource , $ area = null ) { if ( static :: instance ( $ area ) -> use_locks ( ) ) { flock ( $ resource , LOCK_UN ) ; } fclose ( $ resource ) ; }
Close file resource & unlock
58,360
public static function file_info ( $ path , $ area = null ) { $ info = array ( 'original' => $ path , 'realpath' => '' , 'dirname' => '' , 'basename' => '' , 'filename' => '' , 'extension' => '' , 'mimetype' => '' , 'charset' => '' , 'size' => 0 , 'permissions' => '' , 'time_created' => '' , 'time_modified' => '' , ) ;...
Get detailed information about a file
58,361
public static function strip ( $ text = '' , array $ allowedTags = [ ] ) : string { $ text = \ htmlspecialchars_decode ( ( string ) $ text , ENT_COMPAT | ENT_HTML5 ) ; foreach ( $ allowedTags as $ tag ) { $ text = \ preg_replace ( '|<(/?' . $ tag . '\ ?/?)>|i' , '{{{{\\1}}}}' , $ text ) ; $ text = \ preg_replace ( '|<(...
Strips tags from text . Preserves allowed tags .
58,362
private function source ( ) { $ source_url = 'https://www.iso.org/obp/ui/' ; file_get_contents ( $ source_url ) ; foreach ( $ http_response_header as $ header ) { if ( substr ( $ header , 0 , 10 ) != 'Set-Cookie' ) { continue ; } $ cookie = explode ( ';' , substr ( $ header , 12 ) ) [ 0 ] ; } $ resource_info = file_get...
Return the raw data source .
58,363
public function build ( ) { $ countries = [ ] ; $ alpha3_index = [ ] ; $ numeric3_index = [ ] ; $ source = json_decode ( substr ( $ this -> source ( ) , 8 ) ) [ 0 ] ; foreach ( $ source -> changes [ 1 ] [ 2 ] [ 2 ] as $ index => $ country ) { if ( $ index < 2 ) { continue ; } $ countries [ $ country [ 4 ] ] = [ 'name' ...
Generate the class and save it to the filesystem .
58,364
public static function imageFile ( $ dir = null , $ width = 800 , $ height = 600 , $ format = 'png' , $ fullPath = true , $ text = null , $ textColor = null , $ backgroundColor = null , $ fontPath = null ) { $ dir = is_null ( $ dir ) ? sys_get_temp_dir ( ) : $ dir ; if ( ! is_dir ( $ dir ) || ! is_writable ( $ dir ) ) ...
Generate a new image to disk and return its location .
58,365
private function invoke ( $ fn , $ params = [ ] ) { if ( is_callable ( $ fn ) ) { call_user_func_array ( $ fn , $ params ) ; } elseif ( preg_match ( '/@/' , $ fn ) !== false ) { list ( $ controller , $ method ) = explode ( '@' , $ fn ) ; if ( class_exists ( $ controller ) ) { if ( call_user_func_array ( array ( new $ c...
Call the function
58,366
public function route ( $ methods , string $ pattern , $ callback ) { $ methods = explode ( "|" , $ methods ) ; if ( empty ( $ methods ) ) throw new \ RuntimeException ( 'Invalid methods provided' ) ; $ methods = $ this -> validateMethods ( $ methods ) ; foreach ( $ methods as $ method ) $ this -> routes [ $ method ] [...
Store a route and a handling function to be executed when accessed using one of the specified methods .
58,367
public function getOptionsResolver ( ) { if ( null === $ this -> optionsResolver ) { if ( null !== $ this -> parent ) { $ this -> optionsResolver = clone $ this -> parent -> getOptionsResolver ( ) ; } else { $ this -> optionsResolver = new OptionsResolver ( ) ; } $ this -> innerType -> setDefaultOptions ( $ this -> opt...
Returns the configured options resolver used for this type .
58,368
public function setAuthors ( $ post ) { $ username = $ post -> getAuthor ( ) -> getUsername ( ) ; if ( in_array ( $ username , array_keys ( $ this -> config [ 'authors' ] ) ) ) { if ( in_array ( $ username , $ this -> authorsName ) ) { $ this -> authors [ $ username ] -> setPost ( $ post ) ; } else { $ this -> authors ...
Set Posts on author
58,369
public function save ( EntityInterface $ entity , array $ data = [ ] ) { $ this -> entity = $ entity ; $ query = $ this -> getUpdateQuery ( ) ; $ data = $ this -> getData ( ) ; $ save = $ this -> triggerBeforeSave ( $ query , $ entity , $ data ) ; $ query -> set ( $ save -> params ) -> execute ( ) ; $ lastId = $ query ...
Saves current entity object to database
58,370
public function delete ( EntityInterface $ entity ) { $ this -> entity = $ entity ; $ primaryKey = $ this -> getDescriptor ( ) -> getPrimaryKey ( ) -> getName ( ) ; $ table = $ this -> getDescriptor ( ) -> getTableName ( ) ; $ sql = Sql :: createSql ( $ this -> getAdapter ( ) ) ; $ this -> triggerBeforeDelete ( $ entit...
Deletes current entity from database
58,371
protected function setUpdateCriteria ( Sql \ SqlInterface $ query , $ primaryKey , $ table ) { $ key = "{$table}.{$primaryKey} = :id" ; $ query -> where ( [ $ key => [ ':id' => $ this -> entity -> { $ primaryKey } ] ] ) ; return $ query ; }
Adds the update criteria for an update query
58,372
protected function getData ( ) { $ data = [ ] ; $ fields = $ this -> getDescriptor ( ) -> getFields ( ) ; foreach ( $ fields as $ field ) { $ data [ $ field -> getField ( ) ] = $ this -> entity -> { $ field -> getName ( ) } ; } return $ data ; }
Gets data to be used in queries
58,373
public function createFrom ( $ data ) { if ( $ data instanceof RecordList ) { return $ this -> createMultiple ( $ data ) ; } return null == $ data ? null : $ this -> createSingle ( $ data ) ; }
Creates an entity object from provided data
58,374
protected function createSingle ( array $ source ) { $ data = [ ] ; foreach ( $ this -> getDescriptor ( ) -> getFields ( ) as $ field ) { if ( array_key_exists ( $ field -> getField ( ) , $ source ) ) { $ data [ $ field -> getName ( ) ] = $ source [ $ field -> getField ( ) ] ; } } $ class = $ this -> getDescriptor ( ) ...
Creates an entity for provided row array
58,375
protected function createMultiple ( RecordList $ source ) { $ data = [ ] ; foreach ( $ source as $ item ) { $ data [ ] = $ this -> createSingle ( $ item ) ; } return new EntityCollection ( $ this -> getEntityClassName ( ) , $ data ) ; }
Creates an entity collection for provided record list
58,376
protected function registerEntity ( EntityInterface $ entity ) { Orm :: getRepository ( $ this -> getEntityClassName ( ) ) -> getIdentityMap ( ) -> set ( $ entity ) ; return $ this ; }
Sets the entity in the identity map of its repository .
58,377
protected function removeEntity ( EntityInterface $ entity ) { Orm :: getRepository ( $ this -> getEntityClassName ( ) ) -> getIdentityMap ( ) -> remove ( $ entity ) ; }
Removes the entity from the identity map of its repository .
58,378
public function setLine ( $ line ) { if ( ! is_string ( $ line ) ) { throw new InvalidArgumentException ( 'Expected a string, but got ' . gettype ( $ line ) ) ; } $ this -> line = $ line ; }
Set the line .
58,379
public function url ( string $ url , ? array $ schemas = null , ? string $ defaultSchema = null ) : bool { if ( ! $ this -> hasSchema ( $ url ) && ! empty ( $ defaultSchema ) ) { $ defaultSchema = $ this -> trimSchema ( $ defaultSchema ) ; if ( ! empty ( $ defaultSchema ) ) { $ url = "$defaultSchema://{$this->trimURL($...
Check if URL is valid .
58,380
public static function getEmail ( $ config = null , $ reset = true , $ className = null ) { if ( empty ( $ config ) ) { $ config = Common :: read ( 'Email.config' , 'default' ) ; } if ( empty ( $ className ) ) { $ className = Common :: read ( 'Email.classname' , 'CakeEmail' ) ; } list ( $ plugin , $ className ) = plugi...
Get email instance .
58,381
public static function getLog ( $ className = null ) { if ( empty ( $ className ) ) { $ className = Common :: read ( 'Log.classname' , 'CakeLog' ) ; } list ( $ plugin , $ className ) = pluginSplit ( $ className , true ) ; $ key = 'CommonLog' ; if ( ! ClassRegistry :: isKeySet ( 'CommonLog' ) ) { App :: uses ( $ classNa...
Get log instance .
58,382
public static function random ( $ len = 20 , $ char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ) { $ str = '' ; for ( $ ii = 0 ; $ ii < $ len ; $ ii ++ ) { $ str .= $ char [ mt_rand ( 0 , strlen ( $ char ) - 1 ) ] ; } return $ str ; }
Generates a random string .
58,383
public static function reader ( $ config = null , $ default = false ) { if ( empty ( $ config ) ) { $ config = array ( 'id' => 'json' , 'className' => 'JsonReader' , 'location' => 'Common.Configure' ) ; } if ( ! is_array ( $ config ) ) { $ config = array ( 'id' => $ config , 'className' => ucfirst ( $ config ) . 'Reade...
Setup configuration reader .
58,384
public static function startTimer ( $ name , $ message = null ) { if ( ! Reveal :: is ( 'DebugKit.running' ) ) { return ; } App :: uses ( 'DebugTimer' , 'DebugKit.Lib' ) ; DebugTimer :: start ( $ name , $ message ) ; }
Starts a benchmarking timer only if DebugKit is enabled .
58,385
public static function url ( $ url ) { if ( is_array ( $ url ) || ( is_string ( $ url ) && ( preg_match ( '@^' . implode ( '|' , Common :: $ uriSchemes ) . ':@i' , $ url ) || preg_match ( '@^#@i' , $ url ) ) ) ) { return $ url ; } $ reset = Configure :: check ( 'Config.language' ) && $ lang = Configure :: read ( 'Confi...
Transform CakePHP related URL strings into an array .
58,386
public static function wiki ( $ page = 'home' , $ repo = null ) { if ( empty ( $ repo ) ) { try { $ plugin = Reveal :: plugin ( Reveal :: path ( true ) ) ; } catch ( Exception $ e ) { } if ( empty ( $ plugin ) ) { throw new Exception ( ) ; } $ repo = 'gourmet/' . strtolower ( $ plugin ) ; } return sprintf ( 'https://gi...
Generate plugin s wiki uri .
58,387
public function checkSecure ( ) { if ( $ this -> secure === null ) return true ; $ in_secure = isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] === 'on' ; return ( $ this -> secure && $ in_secure ) || ( ! $ this -> secure && ! $ in_secure ) ; }
checking secure setting
58,388
public function methodName2URL ( $ method ) { if ( ! $ this -> restful ) return parent :: methodName2URL ( $ method ) ; $ method = preg_replace ( '/Action$/i' , '' , $ method ) ; $ method = preg_replace ( '/^(' . self :: HTTP_METHOD_ANY . ')/i' , '' , $ method ) ; return trim ( strtolower ( preg_replace ( '/[A-Z]/' , '...
getFooBarZooAction to foo - bar - zoo
58,389
public function mapResult ( ResultIterator $ result ) { if ( $ result -> countRows ( ) == 0 ) return null ; $ this -> columnTypes = $ result -> getColumnTypes ( ) ; if ( $ this -> defaultClass != 'stdClass' || ! is_null ( $ this -> resultMap ) ) $ this -> buildTypeHandlerList ( ) ; return $ this -> map ( $ result -> fe...
Returns a mapped object from a result iterator
58,390
public function getConfig ( ? string $ key = null , ? string $ subKey = null ) { if ( $ key === null ) { return $ this -> config ; } $ key = ( string ) $ key ; $ subKey = $ subKey === null ? null : ( string ) $ subKey ; if ( array_key_exists ( $ key , $ this -> config ) ) { if ( $ subKey !== null ) { return array_key_e...
Quick access to a configuration node
58,391
public function getPassword ( ) : IHashedPassword { return new class implements IHashedPassword { public function getHash ( ) : string { } public function getAlgorithm ( ) : string { } public function getCostFactor ( ) : int { } public function toArray ( ) : array { } public function hydrate ( array $ properties ) { } ...
Gets the user s hashed password .
58,392
protected function getMigrationFile ( $ name , $ path = false ) { $ path = $ path ? $ path : $ this -> migrationPath ; return $ path . DIRECTORY_SEPARATOR . $ name . '.php' ; }
gets path to migration file
58,393
public function actionDataDump ( $ table , $ remove = 1 ) { $ className = 'm' . gmdate ( 'ymd_His' ) . '_' . $ table . '_dump' ; if ( ! $ data = $ this -> db -> createCommand ( "SELECT * FROM {{{$table}}}" ) -> queryAll ( ) ) { throw new Exception ( "No data found" ) ; } $ columns = DbHelper :: dataColumns ( $ data ) ;...
Generate any table data migration into
58,394
public function actionCreate ( $ name , $ module = null ) { if ( ! empty ( $ module ) ) { if ( empty ( $ this -> allMigrationPaths [ $ module ] ) ) { throw new Exception ( "Module $module does not exist or does not contains 'migrations' directory" ) ; } $ this -> migrationPath = $ this -> allMigrationPaths [ $ module ]...
Creates a new migration .
58,395
protected function setModuleMigrationPaths ( $ module ) { $ paths = [ Yii :: getAlias ( '@app/runtime/tmp' ) ] ; if ( isset ( $ this -> allMigrationPaths [ $ module ] ) ) { $ paths [ $ module ] = $ this -> allMigrationPaths [ $ module ] ; } $ this -> allMigrationPaths = $ paths ; $ this -> setMigrationFiles ( ) ; }
Sets modules array - leaves only module migrations .
58,396
protected function compare ( array $ a , array $ b ) : ArrayDelta { $ delta = [ ] ; foreach ( $ a as $ key => $ value ) { if ( array_key_exists ( $ key , $ b ) ) { if ( is_array ( $ value ) ) { $ deltaX = self :: compare ( $ value , $ b [ $ key ] ) ; if ( count ( $ deltaX ) ) { $ delta [ $ key ] = $ deltaX ; } } else {...
Compute the difference of 2 arrays - multi dimensions supported
58,397
protected function getGenericPropertyReader ( ) : Closure { $ reader = function & ( $ object , $ property ) { $ value = & Closure :: bind ( function & ( ) use ( $ property ) { return $ this -> { $ property } ; } , $ object , $ object ) -> __invoke ( ) ; return $ value ; } ; return $ reader ; }
Returns a callback that can read private variables from object .
58,398
public function setConfig ( $ key , $ value = '' ) { if ( is_array ( $ key ) ) { $ this -> _config = array_merge ( $ this -> _config , $ key ) ; } else { $ this -> _config [ $ key ] = $ value ; } $ this -> updateConfig ( ) ; return $ this ; }
Set config class
58,399
public function getConfig ( $ index = '' ) { if ( $ index === '' ) { return $ this -> _config ; } if ( isset ( $ this -> _config [ $ index ] ) ) { return $ this -> _config [ $ index ] ; } return null ; }
get config value